<!-- $Id:addcourse:tab3   Author:liuricheng   Time:2013-08-28  [modify]-->
<script src="__PUBLIC__/plugs/artDialog/artDialog.source.js?skin=default"></script>

<script type="text/javascript">
	var upload1;
	window.onload = function() {
		upload1 = new SWFUpload({
			//Backend Settings
			upload_url: "__URL__/upload_course_zip",
			post_params: {"PHPSESSID" : "78797997979798798"},
			
			// File Upload Settings
			file_size_limit : "102400",	// 100MB
			file_types : "*.*",
			file_types_description : "All Files",
			file_upload_limit : "10",
			file_queue_limit : "0",

			// Event Handler Settings (all my handlers are in the Handler.js file)
			file_dialog_start_handler : fileDialogStart,
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
			upload_complete_handler : uploadComplete,

			// Button Settings
			button_image_url : "__PUBLIC__/plugs/uploadHelper/multiinstancedemo/XPButtonUploadText_61x22.png",
			button_placeholder_id : "spanButtonPlaceholder1",
			button_width: 61,
			button_height: 22,
			
			// Flash Settings
			flash_url : "__PUBLIC__/plugs/uploadHelper/swfupload/swfupload.swf",
			
			custom_settings : {
				progressTarget : "fsUploadProgress1",
				cancelButtonId : "btnCancel1"
			},
			
			// Debug Settings
			debug: false
		});
		
		upload1.uploadSuccess	=	function(file, serverData, responseReceived){
			file = this.unescapeFilePostParams(file);
			this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
			//将服务端发送过来的json数据进行格式化
			var msg	=	eval('('+ serverData +')');				
			if(msg.data == 1){
				$('#download_url').attr('value',msg.info.url);
				$('#download_text').text(msg.info.url);
				//显示删除按钮
				$('#delete_download').show();
			}
			else{
				
			}
		}
	 }
</script>



<div>
	<div id="form1">
		<table>
			<tr valign="top">
				<td>
					<div>
						<div class="fieldset flash" id="fsUploadProgress1">
							<span class="legend">上传音频</span>
						</div>
						<div style="padding-left: 5px;">
							<span id="spanButtonPlaceholder1"></span>
							<input id="btnCancel1" type="button" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
							<br />
						</div>
					</div>
				</td>
				<td>
					<div class="mp20">
						<span id="download_text">{$course.download_url}</span>
						<span id="delete_download" onclick="delete_course_zip();" 
							  class="<if condition="($course.download_url eq '') or ($course.download_url eq null)">hide<else/></if> ml20" style="cursor:pointer;">删除
						</span>
						<input id="download_url" type="hidden" name="download_url" value="{$course.download_url}"/>
					</div>
				</td>
			</tr>
		</table>	
	</div>
</div> 

<script type="text/javascript">
	//删除课堂音频包
	function delete_course_zip(){
		//获取地址
		var url			=	$('#download_url').val();
		var course_id	=	$('#course_id').val();
		if(url.length == 0){
			$('#delete_download').hide();
			return;
		}
		//ajax 删除文件
		var dialog = art.dialog({id: 'N3690',title: false});
		$.ajax({
		    url: '__URL__/delete_course_zip',
		    type:'post',
		    dataType:'json',
		    data:{url:url,course_id:course_id},
		    success: function (msg) {
		    	dialog.content(msg.info).time(1);
		        if(msg.data == 1){
		        	 $('#delete_download').hide();
				     $('#download_text').text('');
				     $('#download_url').attr('value','');
		        }
		    },
		    cache: false
		});
	}
</script>












